/*
 * Created by JFormDesigner on Mon Jun 03 16:17:30 EDT 2013
 */

package MaintMenu.VenPricingUpdMasterFiles;

import CreateNewItem.SQLEXEC;
import MaintMenu.VenPricingUpdMasterFiles.Mast1ToMastMenu.MastMenu;
import MaintMenu.VenPricingUpdMasterFiles.Mast1ToMastMenu.Trn6CategoryUpdateMasterfiles;
import MaintMenu.VenPricingUpdTBLN.FindItemByVendorSheetPL;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * @author Jason Chi
 */
public class VendorPricingUpdateMasterFiles extends JPanel {
    public VendorPricingUpdateMasterFiles() {
        initComponents();
    }

    private void buttonAPActionPerformed(ActionEvent e) {
        AP ap= new AP();
        JOptionPane.showMessageDialog(null, "Execute Complete");
    }

    private void buttonYCCActionPerformed(ActionEvent e) {
        YCC ycc= new YCC();
        JOptionPane.showMessageDialog(null, "Execute Complete");
    }

    private void buttonTESTActionPerformed(ActionEvent e) {
        test t1 = new test();
        JOptionPane.showMessageDialog(null,"Execute Complete");

    }

    private void tygtwActionPerformed(ActionEvent e) {
        TYGtw tyGtw = new TYGtw();
        JOptionPane.showMessageDialog(null,"Execute Complete");
    }

    private void tygtxActionPerformed(ActionEvent e) {
        TYGtx tyGtx = new TYGtx();
        JOptionPane.showMessageDialog(null,"Execute Complete");
    }

    private void generaActionPerformed(ActionEvent e) {
        GENERA gen = new GENERA();
        JOptionPane.showMessageDialog(null,"Execute Complete");
    }

    private void depoActionPerformed(ActionEvent e) {
        DEPO depo1 = new DEPO();
        JOptionPane.showMessageDialog(null,"Execute Complete");
    }

    private void dnkworkActionPerformed(ActionEvent e) {
        Trn6Category trn6Category = new Trn6Category();
        JOptionPane.showMessageDialog(null,"Execute Complete");
    }

    private void updAllActionPerformed(ActionEvent e) {
        AP ap= new AP();
        System.out.println("\nAP Complete\n");
        YCC ycc= new YCC();
        System.out.println("\nYCC Complete\n");
        TYGtw tyGtw = new TYGtw();
        System.out.println("\nTW Complete\n");
        TYGtx tyGtx = new TYGtx();
        System.out.println("\nTX Complete\n");
        GENERA gen = new GENERA();
        System.out.println("\nGN Complete\n");
        DEPO depo1 = new DEPO();
        System.out.println("\nDP Complete\n");
        JOptionPane.showMessageDialog(null,"Execute Complete");

    }

    private void button1ActionPerformed(ActionEvent e) {
        //Disable due to currently use MAST, instead of MAST1 (MAST1 will no longer be used)
        MastMenu mm= new MastMenu();
        mm.setVisible(true);
        //Trn6Category trn2 = new Trn6Category();
    }

    private void ManualSQLStatementActionPerformed(ActionEvent e) {
        ManualSqlStatement m1 = new ManualSqlStatement();
        JOptionPane.showMessageDialog(null,"Execute Complete");
    }

    private void vendorFindByPLActionPerformed(ActionEvent e) {
        String a=vendToFind.getText();
        String b=partlinkToFind.getText();
        int c=Integer.getInteger(sheetToFind.getText());

        System.out.println(a + b + c);


        FindItemByVendorSheetPL findItemByVendorSheetPL = new FindItemByVendorSheetPL(a,b,c);



        //                   0              1              2               3          4       5            6               7             8             9            10             11           12
//        String[] sheet = {"_costDepo1","_costDepo2", "_costgenera", "_costycc","_costap","_costtygtx1","_costtygtx2","_costtygtx3","_costtygtw1","_costtygtw2","_costtygtw3","_costtygtw4","_costtygtw5"};

//        System.out.println("a searching :"+plFind);
//
//        for (int x=0;x<sheet.length;x++){
//            String plField=null;
//            if (x==0 || x==1 ){
//                plField ="[partslink1]";
//            }else if (x==2){
//                plField ="[partslink #]";
//            }else if (x==3){
//                plField ="partlink";
//            }else if (x==4){
//                plField ="prtlnk";
//            }else if (x>=5 && x<=7){
//                plField ="[partslink #]";
//            }else if (x>=8 && x<=12){
//                plField ="partslink";
//            }else {}
//
////            System.out.println("for statment running");
//
//
////            System.out.println("field :"+plField);
//            System.out.println("Search table :"+sheet[x]);
//            String statement="select * from "+sheet[x]+" where "+ plField + " = '"+plFind+"'";
//            System.out.println("SQL :"+statement);
//            sqlexec.sqlprocess(statement);
//
//
//
//        }


    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        // Generated using JFormDesigner Evaluation license - jason Chi
        label1 = new JLabel();
        buttonAP = new JButton();
        label2 = new JLabel();
        buttonYCC = new JButton();
        label3 = new JLabel();
        ManualSQLStatement = new JButton();
        tygtw = new JButton();
        tygtx = new JButton();
        genera = new JButton();
        depo = new JButton();
        updAll = new JButton();
        label4 = new JLabel();
        label5 = new JLabel();
        label6 = new JLabel();
        label7 = new JLabel();
        masTocatUpd = new JButton();
        dnkWork = new JButton();
        vendToFind = new JTextField();
        partlinkToFind = new JTextField();
        sheetToFind = new JTextField();
        vendorFindByPL2 = new JButton();

        //======== this ========
        setPreferredSize(new Dimension(400, 900));

        // JFormDesigner evaluation mark
        setBorder(new javax.swing.border.CompoundBorder(
            new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
                "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,
                javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
                java.awt.Color.red), getBorder())); addPropertyChangeListener(new java.beans.PropertyChangeListener(){public void propertyChange(java.beans.PropertyChangeEvent e){if("border".equals(e.getPropertyName()))throw new RuntimeException();}});


        //---- label1 ----
        label1.setText("Vendor Pricing Update TO MAST!");
        label1.setForeground(Color.blue);
        label1.setFont(new Font("sansserif", Font.BOLD, 24));

        //---- buttonAP ----
        buttonAP.setText("AP (GORDON)");
        buttonAP.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                buttonAPActionPerformed(e);
            }
        });

        //---- label2 ----
        label2.setText("BC,HF,OT");

        //---- buttonYCC ----
        buttonYCC.setText("YCC (PROTEC)");
        buttonYCC.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                buttonYCCActionPerformed(e);
            }
        });

        //---- label3 ----
        label3.setText("BC,OT");

        //---- ManualSQLStatement ----
        ManualSQLStatement.setText("Manual SQL Statement");
        ManualSQLStatement.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                ManualSQLStatementActionPerformed(e);
            }
        });

        //---- tygtw ----
        tygtw.setText("TYG Taiwan");
        tygtw.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                tygtwActionPerformed(e);
            }
        });

        //---- tygtx ----
        tygtx.setText("TYG Texas");
        tygtx.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                tygtxActionPerformed(e);
            }
        });

        //---- genera ----
        genera.setText("GENERA (TYC)");
        genera.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                generaActionPerformed(e);
            }
        });

        //---- depo ----
        depo.setText("DEPO (MAXZONE)");
        depo.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                depoActionPerformed(e);
            }
        });

        //---- updAll ----
        updAll.setText("UPDATE ALL VENDORS");
        updAll.setToolTipText("Copy MAST11 to MAST1 and updates 6 Cats");
        updAll.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                updAllActionPerformed(e);
            }
        });

        //---- label4 ----
        label4.setText("BC, HF,MR,CL,OT");

        //---- label5 ----
        label5.setText("BC, CL");

        //---- label6 ----
        label6.setText("MR,CL,LT");

        //---- label7 ----
        label7.setText("MR,CL,LT");

        //---- masTocatUpd ----
        masTocatUpd.setText("Transfer Master files to CATs ");
        masTocatUpd.setToolTipText("COPY from Mast11 to Mast1, Transfer to 6 Cats, Price update form TBLINVENTORY");
        masTocatUpd.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                dnkworkActionPerformed(e);
            }
        });

        //---- dnkWork ----
        dnkWork.setText("DNKWORK Complete");
        dnkWork.setToolTipText("COPY from Mast11 to Mast1 only. Very long process approx 1 hr)");
        dnkWork.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                button1ActionPerformed(e);
            }
        });

        //---- vendToFind ----
        vendToFind.setText("TW");

        //---- partlinkToFind ----
        partlinkToFind.setText("PL");

        //---- sheetToFind ----
        sheetToFind.setText("1");

        //---- vendorFindByPL2 ----
        vendorFindByPL2.setText("Find Vendor(ng)");
        vendorFindByPL2.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                vendorFindByPLActionPerformed(e);
            }
        });

        GroupLayout layout = new GroupLayout(this);
        setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup()
                .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup()
                                .addGroup(layout.createSequentialGroup()
                                        .addComponent(buttonAP, GroupLayout.PREFERRED_SIZE, 182, GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(label2, GroupLayout.PREFERRED_SIZE, 123, GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
                                        .addGroup(layout.createSequentialGroup()
                                                .addComponent(depo, GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE)
                                                .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(label7, GroupLayout.PREFERRED_SIZE, 123, GroupLayout.PREFERRED_SIZE))
                                        .addGroup(layout.createSequentialGroup()
                                                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                                                        .addComponent(tygtw, GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE)
                                                        .addComponent(buttonYCC, GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE)
                                                        .addComponent(tygtx, GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE)
                                                        .addComponent(genera, GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE))
                                                .addGap(12, 12, 12)
                                                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                                                        .addComponent(label3, GroupLayout.PREFERRED_SIZE, 123, GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(label4, GroupLayout.PREFERRED_SIZE, 123, GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(label5, GroupLayout.PREFERRED_SIZE, 123, GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(label6, GroupLayout.PREFERRED_SIZE, 123, GroupLayout.PREFERRED_SIZE)))))
                        .addContainerGap())
                .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(label1)
                        .addGap(62, 62, 62))
                .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                                .addComponent(updAll, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(layout.createSequentialGroup()
                                        .addContainerGap(46, Short.MAX_VALUE)
                                        .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                                                .addGroup(layout.createSequentialGroup()
                                                        .addComponent(vendToFind, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
                                                        .addGap(12, 12, 12)
                                                        .addComponent(partlinkToFind, GroupLayout.PREFERRED_SIZE, 94, GroupLayout.PREFERRED_SIZE)
                                                        .addGap(18, 18, 18)
                                                        .addComponent(sheetToFind, GroupLayout.PREFERRED_SIZE, 45, GroupLayout.PREFERRED_SIZE)
                                                        .addGap(77, 77, 77)
                                                        .addComponent(vendorFindByPL2))
                                                .addGroup(layout.createSequentialGroup()
                                                        .addComponent(dnkWork)
                                                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                                        .addComponent(masTocatUpd))
                                                .addComponent(ManualSQLStatement))
                                        .addGap(12, 12, 12)))
                        .addGap(38, 38, 38))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup()
                .addGroup(layout.createSequentialGroup()
                        .addComponent(label1)
                        .addGap(15, 15, 15)
                        .addGroup(layout.createParallelGroup()
                                .addComponent(label2, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
                                .addComponent(buttonAP))
                        .addGap(5, 5, 5)
                        .addGroup(layout.createParallelGroup()
                                .addComponent(label3, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
                                .addComponent(buttonYCC))
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup()
                                .addGroup(layout.createSequentialGroup()
                                        .addComponent(tygtw)
                                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(tygtx)
                                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(genera)
                                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(depo))
                                .addGroup(layout.createSequentialGroup()
                                        .addComponent(label4, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(label5, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(label6, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(label7, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(updAll)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(dnkWork)
                                .addComponent(masTocatUpd))
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ManualSQLStatement)
                        .addGap(2, 2, 2)
                        .addGroup(layout.createParallelGroup()
                                .addComponent(vendToFind, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addComponent(partlinkToFind, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addComponent(sheetToFind, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addComponent(vendorFindByPL2)))
        );
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    // Generated using JFormDesigner Evaluation license - jason Chi
    private JLabel label1;
    private JButton buttonAP;
    private JLabel label2;
    private JButton buttonYCC;
    private JLabel label3;
    private JButton ManualSQLStatement;
    private JButton tygtw;
    private JButton tygtx;
    private JButton genera;
    private JButton depo;
    private JButton updAll;
    private JLabel label4;
    private JLabel label5;
    private JLabel label6;
    private JLabel label7;
    private JButton masTocatUpd;
    private JButton dnkWork;
    private JTextField vendToFind;
    private JTextField partlinkToFind;
    private JTextField sheetToFind;
    private JButton vendorFindByPL2;
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
